define([],
    function() {
        var app = angular.module('App.home');
        app.controller('projects.detail.locationCtrl', ['$scope', '$rootScope', '$state', '$stateParams', 'showMsg', 'allProjects', 'curPrj', 'PublicMap',
            function($scope, $rootScope, $state, $stateParams, showMsg, allProjects, curPrj, PublicMap) {

                if (!curPrj.center) {
                    showMsg("点击地图来指定位置", 'note');
                }
                var map = new PublicMap('map', {
                    center: PublicMap.getCenter(curPrj), //上海坐标,默认为地图中心
                    zoom: curPrj.center ? 16 : 13,
                    maxZoom: 18,
                    minZoom: 8,
                    zoomControl: true,
                    doubleClickZoom: false
                });
                map.loadPublicMap('天地图');
                if (curPrj.center) {
                    map.addPrjMarker(curPrj.center);
                }
                map.on('click', function(event) {
                    curPrj.center = map.addClickedPoint(event.latlng);
                    curPrj.postCenter();
                });

            }
        ]);
    });
